package com.email.impl;

import com.email.IEmailParser;

import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * eml 文件解析
 * 
 * @author wanghong
 * 
 */
public class EMLParser implements IEmailParser {


	public void parse(String path, String name, String rootPath) throws Exception {
		if (name.toLowerCase().indexOf(".eml") <= 0) {
			throw new Exception("eml文件类型不匹配" + name);
		}
		Properties props = System.getProperties();
		props.put("mail.host", "smtp.dummydomain.com");
		props.put("mail.transport.protocol", "smtp");

		Session ms = Session.getDefaultInstance(props, null);
		File file = new File(path + "\\" + name);
		InputStream is = new FileInputStream(file);
		MimeMessage msg = new MimeMessage(ms, is);
		MailParser mp = new MailParser(msg);
	}
}
